package com.xc.service.impl;

import com.xc.dto.ResultDTO;
import com.xc.entity.NavEntity;
import com.xc.entity.PermissionEntity;
import com.xc.mapper.NavMapper;
import com.xc.mapper.PermissionMapper;
import com.xc.service.NavService;
import com.xc.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;


    @Override
    public ResultDTO add(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(permissionMapper.add(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO update(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(permissionMapper.update(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO delete(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(permissionMapper.delete(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO updateEnable(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(permissionMapper.updateEnable(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO findById(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .code(0)
                .data(permissionMapper.findById(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO findAll(PermissionEntity permissionEntity) {

        return ResultDTO.builder()
                .code(0)
                .code(0)
                .count(permissionMapper.count(permissionEntity))
                .data(permissionMapper.findAll(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO count(PermissionEntity permissionEntity) {
        return ResultDTO.builder()
                .code(0)
                .code(0)
                .count(permissionMapper.count(permissionEntity))
                .build();
    }

    @Override
    public ResultDTO findByName(PermissionEntity permissionEntity) {
        return null;
    }
}
